/**
 * AdminJ LayuiFormRender
 * @author adminj
 * @date 2021-8
 * @description  此类为实例化HTML，把组件的HTML写到BODY [开源不易，如果可能请留下版权信息]
 * @version 1.0
 *
 */
layui.link(layui.cache.base + 'adminJFormRenderCompontsHtml.css')
layui.define(function (exports) {

    var adminJFormRenderCompontsHtml = {
        //初始化HTML
        baseHtml: function () {
            var html = '<div class="layui-form">\n' +
              '        <ul>\n' +
              '            <li class="adminj-ds-left" id="leftDragButtons"></li>\n' +
              '            <li class="adminj-ds-center" id=\'sortable\'></li>\n' +
              '            <li class="adminj-ds-right">\n' +
              '\n' +
              '                <div class="layui-tab layui-tab-brief">\n' +
              '                    <ul class="layui-tab-title">\n' +
              '                        <li class="layui-this">属性设置</li>\n' +
              '                    </ul>\n' +
              '                    <div class="layui-tab-content" style="height: 100px;">\n' +
              '                        <div class="layui-tab-item layui-show" id="propertiesDiv" style="padding-bottom: 20px;">\n' +
              '                        </div>\n' +
              '                    </div>\n' +
              '                </div>\n' +
              '\n' +
              '            </li>\n' +
              '        </ul>\n' +
              '    </div>\n' +
              '\n' +
              '\n' +
              '\n' +
              '\n' +
              '    <!--所有的组件 display:block 后可以直接在浏览器修改预览-->\n' +
              '    <span id="adminj_cpts_items" style="display: none">\n' +

              text_compont +
              hidden_compont +
              password_compont +
              textarea_compont +
              date_compont +
              switch_compont +
              select_compont +
              select2_compont +
              radio_compont +
              checkbox_compont +
              dateRange_compont +
              editor_compont +
              uploadImage_compont +
              uploadImages_compont +
              submitData_compont +

              '    </span>\n' +
              '    <!--layui template生成左边的拖放button-->\n' +
              '    <script id="leftButtonTemplate" type="text/html">\n' +
              '    {{#  layui.each(d.list, function(i, groups){ }}\n' +
              '    <div class="layui-tab layui-tab-brief">\n' +
              '        <ul class="layui-tab-title">\n' +
              '            <li class="layui-this">{{ groups.groupName }}</li>\n' +
              '        </ul>\n' +
              '        <div class="layui-tab-content">\n' +
              '            <div class="layui-tab-item layui-show">\n' +
              '                <div class="layui-row">\n' +
              '                    {{# layui.each(groups.list, function(index, item){ }}\n' +
              '                    <div class="layui-col-xs6">\n' +
              '                        <div>\n' +
              '                            <button type="button" cpt_id="{{ item.id }}"\n' +
              '                                    class="layui-btn layui-btn-primary adminj-left-darg-button">{{ item.name }}\n' +
              '                            </button>\n' +
              '                        </div>\n' +
              '                    </div>\n' +
              '                    {{# }); }}\n' +
              '                </div>\n' +
              '            </div>\n' +
              '        </div>\n' +
              '    </div>\n' +
              '    {{#  }); }}\n' +
              '</script>\n' +
              '    <!--点击中间组件后出现的删除和复制工具条-->\n' +
              '<script id="toolsTemplate" type="text/html">\n' +
              '<div class="action-tools adminj-item-top-left-tools">\n' +
              ' &nbsp;&nbsp;<i class="layui-icon layui-icon-screen-full"></i>&nbsp;&nbsp;\n' +
              '</div>\n' +
              '<div class="action-tools adminj-item-bottom-right-tools">\n' +
              ' &nbsp;&nbsp;<i class="layui-icon layui-icon-delete"></i>&nbsp;&nbsp;\n' +
              ' <i class="layui-icon layui-icon-layer"></i>&nbsp;&nbsp;\n' +
              '</div>\n' +
              '</script>';
            return html;
        },
        init: function (formRender, initConfig) {//所有方法调用之前调用
            //把HTML写到body,如果有传ID就用已有的id div,如果没有就创建一个新的
            var $ = layui.$;
            var id = initConfig.id;
            if (id == undefined) {
                id = 'id_' + new Date().getTime();
                initConfig.id = id;
                $('body').append('<div id="{0}"></div>'.format(id));
            }
            var html = this.baseHtml();
            var $ = layui.$;
            $('#' + id).html(html);
        }
    }


    exports('adminJFormRenderCompontsHtml', adminJFormRenderCompontsHtml);
});